{{!
  Copyright IBM Corp. 2016, 2025
  SPDX-License-Identifier: BUSL-1.1
}}

{{#let (engines-display-data this.model.secretsEngine.type) as |engineDisplayData|}}
  {{#if engineDisplayData.isOldEngine}}
    <PageHeader as |p|>
      <p.top>
        <KeyValueHeader
          @baseKey={{this.model}}
          @path="vault.cluster.secrets.backend"
          @root={{this.root}}
          @showCurrent={{true}}
        />
      </p.top>
      <p.levelLeft>
        <h1 class="title is-3" data-test-backend-configure-title={{this.model.type}}>
          Configure
          {{this.displayName}}
        </h1>
      </p.levelLeft>
    </PageHeader>
  {{else}}
    <Page::Header
      @title={{concat this.model.secretsEngine.id " configuration"}}
      @description={{engineDisplayData.displayName}}
      @icon={{engineDisplayData.glyph}}
    >
      <:breadcrumbs>
        <Page::Breadcrumbs @breadcrumbs={{this.breadcrumbs}} />
      </:breadcrumbs>
      <:actions>
        <Hds::Button
          @color="secondary"
          @route="vault.cluster.secrets.backend.list-root"
          @text="Exit configuration"
          data-test-button="Exit configuration"
        />
      </:actions>
      <:tabs>
        <Mount::ConfigureTabs
          @configRoute="configuration.edit"
          @displayName={{engineDisplayData.displayName}}
          @path={{this.model.secretsEngine.id}}
        />
      </:tabs>
    </Page::Header>
  {{/if}}
{{/let}}

<Toolbar>
  <ToolbarActions>
    <ToolbarLink @route="vault.cluster.secrets.backend" @model={{this.model.id}} data-test-backend-view-link>
      View backend
    </ToolbarLink>
  </ToolbarActions>
</Toolbar>

{{#if (eq this.model.type "ssh")}}
  <SecretEngine::ConfigureSsh @configForm={{this.model.configForm}} @id={{this.model.id}} />
  {{! This "else if" check is preventive. As of writing, all engines using this route, but "ssh", are wif engines }}
{{else if this.isWifEngine}}
  <SecretEngine::ConfigureWif
    @backendPath={{this.model.id}}
    @displayName={{this.displayName}}
    @type={{this.model.type}}
    @configForm={{this.model.configForm}}
  />
{{/if}}